package com.huiyujinrong.qiangdanbao.activity.fragment;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.AppBarLayout;
import android.support.v4.app.Fragment;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.amap.api.location.AMapLocation;
import com.amap.api.location.AMapLocationClient;
import com.amap.api.location.AMapLocationClientOption;
import com.amap.api.location.AMapLocationListener;
import com.huiyujinrong.qiangdanbao.BorrowHelpApp;
import com.huiyujinrong.qiangdanbao.R;
import com.huiyujinrong.qiangdanbao.activity.login.LoginActivity;
import com.huiyujinrong.qiangdanbao.activity.my.MessageActivity;
import com.huiyujinrong.qiangdanbao.adapter.HomeAdapter;
import com.huiyujinrong.qiangdanbao.bean.BannerBean;
import com.huiyujinrong.qiangdanbao.bean.FragmentGrabSingleBean;
import com.huiyujinrong.qiangdanbao.bean.GrabsBean;
import com.huiyujinrong.qiangdanbao.city.CityPicker;
import com.huiyujinrong.qiangdanbao.network.Api;
import com.huiyujinrong.qiangdanbao.utils.SharedHelper;
import com.huiyujinrong.qiangdanbao.utils.WPopupWindow;
import com.huiyujinrong.qiangdanbao.utils.WebViewActivity;
import com.huiyujinrong.qiangdanbao.utils.WheelView;
import com.huiyujinrong.qiangdanbao.widget.AlertDialog;
import com.huiyujinrong.qiangdanbao.widget.MarqueView;
import com.huiyujinrong.qiangdanbao.widget.bannerholder.BannerClickListener;
import com.huiyujinrong.qiangdanbao.widget.bannerholder.BannerHolderView;
import com.huiyujinrong.qiangdanbao.widget.bannerholder.HolderAttr;
import com.huiyujinrong.qiangdanbao.widget.bannerholder.ImageViewBannerLoader;
import com.huiyujinrong.qiangdanbao.widget.bannerholder.loader.SimpleImageLoader;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by ZQXQ-Developer on 2017/6/9.
 */

public class HomeFragment extends Fragment implements FragmentGrabSingleContract.View, AMapLocationListener {

    private static final int GE_REN = 1;
    private static final int QI_YE = 2;
    private static final int GOTOBANNER =3 ;
    public static int RQ_WEBVIEW = 0xFF;


    @BindView(R.id.gd_money_type)
    TextView money_type;

    @BindView(R.id.recyclerView)
    RecyclerView recyclerView;

    @BindView(R.id.banner_holder)
    BannerHolderView banner_holder;

//
//    @BindView(R.id.toolbar_Title)
//    TextView title;

    //    @BindView(R.id.toolbar_Title)
//    ImageView message;
    @BindView(R.id.title_city)
    TextView city;
//
//    @BindView(R.id.title_city)
//    LinearLayout checkCity;

    @BindView(R.id.marqueeView)
    MarqueView marqueeView;

    private List<FragmentGrabSingleBean.list> dataList = new ArrayList<>();

    private FragmentGrabSingleBean bea;

    private int pullNum = 1;

    private FragmentGrabSinglePresenter presenter;

    private HomeAdapter adapter;

    private Toast t;

    private HolderAttr.Builder builder;

    private String city_sheng = "";

    private String city_shi = "";

    private String city_code = "";

    private String type = "";

    private int page_size = 10;

    private List<String> urls;

    @BindView(R.id.gd_type)
    RelativeLayout gd_type;

    @BindView(R.id.appbar_layout)
    AppBarLayout appBarLayout;
    private WPopupWindow popupWindow;

    @BindView(R.id.tvNoMessage)
    TextView tvMessage;

    //    @BindView(R.id.imTrumpet)
//    ImageView imTrumpet;
    private boolean isReflush = false;
    private boolean isLoading = false;
    private boolean isShowMessage = true;

    private boolean isLogin = false;
    private ProgressDialog progressDialog;
    private Context context;

    //声明mLocationOption对象
    public AMapLocationClientOption mLocationOption = null;
    //声明AMapLocationClient类对象
    public AMapLocationClient mlocationClient = null;


    @BindView(R.id.main_sw_ly)
    SwipeRefreshLayout mRefreshLayout;


    @BindView(R.id.goback_item0)
    ImageView goback_item0;

    private List<String> idList;

    //筛选
    private String UserType = "",
            YongTu = "",
            ChengShi = "",
            EDu = "",
            QiXian = "",
            SheBao = "",
            GongJiJin = "",
            LeiXing = "",
            ZhiZhao = "",
            DuiGong = "",
            DuiSi = "";


    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.activity_main, container, false);
        ButterKnife.bind(this, v);
        context = getActivity();
        isLogin = (boolean) SharedHelper.get(getActivity(), "isLogin", false);

        idList = new ArrayList<>();

        presenter = new FragmentGrabSinglePresenter(this, context);
        presenter.start();


        initLocation();
        initView();
        if (!isLogin) {
            showDialog();
        }
        return v;
    }

    @Override
    public void onResume() {
        super.onResume();
        isLogin = (boolean) SharedHelper.get(getActivity(), "isLogin", false);
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        //设置监听
        recyclerView.addOnScrollListener(new MyRecyclerViewScrollListener());

        isLogin = (boolean) SharedHelper.get(getActivity(), "isLogin", false);
        presenter.getBannerHolder();  //post 轮番图
        presenter.findRealTimeGrab();
        isReflush = true;
        isShowMessage = true;
        initData(city_code, type, pullNum, page_size, UserType, YongTu, EDu, QiXian, SheBao, GongJiJin, LeiXing, ZhiZhao, DuiGong, DuiSi);   //post 列表数据

    }

    //滑动监听
    private class MyRecyclerViewScrollListener extends RecyclerView.OnScrollListener {
        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            super.onScrollStateChanged(recyclerView, newState);
            LinearLayoutManager manager = (LinearLayoutManager) recyclerView.getLayoutManager();
            int firstVisibleItemPosition = manager.findFirstVisibleItemPosition();
            // 当不滚动时
            if (newState == RecyclerView.SCROLL_STATE_IDLE) {
                // 判断是否滚动超过一屏
                if (firstVisibleItemPosition == 0) {
                    goback_item0.setVisibility(View.INVISIBLE);
                } else {
                    goback_item0.setVisibility(View.VISIBLE);
                }

            } else if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {//拖动中
                goback_item0.setVisibility(View.INVISIBLE);
            }
        }
    }


    /**
     * 回到列表的第一条
     */
    @OnClick(R.id.goback_item0)
    void goback_item0() {
        recyclerView.smoothScrollToPosition(0);
    }

    /**
     * 新人见面礼
     */
    private void showDialog() {
        final AlertDialog dialog = new AlertDialog(getActivity()).builder();
        dialog.setPositiveButton("立即领取", new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dialog.dismiss();
                Bundle bundle = new Bundle();
                bundle.putString("url", "http://106.15.102.162/jqb-api/qdb_rules/banner_active.html");
                bundle.putInt("mm", 6);
                Intent intent2 = new Intent(getActivity(), WebViewActivity.class);
                intent2.putExtras(bundle);
                startActivity(intent2);
            }
        });
        dialog.setCancelable(true);
        dialog.show();
    }

    @Override
    public void onHiddenChanged(boolean hidden) {
        super.onHiddenChanged(hidden);
        isLogin = (boolean) SharedHelper.get(getActivity(), "isLogin", false);
        presenter.findRealTimeGrab();
//        pullNum = 1;
//        initData(city_code, type, pullNum, page_size, UserType, YongTu, EDu, QiXian, SheBao, GongJiJin, LeiXing, ZhiZhao, DuiGong, DuiSi);
    }


    /**
     * 请求接口
     *
     * @param city_code             城市编码
     * @param type                  借款类型
     * @param pullNum               页码
     * @param page_size             每页大小
     * @param loan_use              用途
     * @param apply_amt             金额
     * @param loan_term             期限
     * @param social_security_state 社保
     * @param house_fund_state      公积金
     * @param industry_type         企业类型
     * @param license_years         执照
     * @param bank_dgls             对公
     * @param bank_dsls             对私
     */
    private void initData(String city_code,
                          String type,
                          int pullNum,
                          int page_size,
                          String user_type,
                          String loan_use,
                          String apply_amt,
                          String loan_term,
                          String social_security_state,
                          String house_fund_state,
                          String industry_type,
                          String license_years,
                          String bank_dgls,
                          String bank_dsls) {
        presenter.getGrabSingleData(city_code,
                type,
                pullNum,
                page_size,
                user_type,
                loan_use,
                apply_amt,
                loan_term,
                social_security_state,
                house_fund_state,
                industry_type,
                license_years,
                bank_dgls,
                bank_dsls);
    }


    /**
     * 跳转 消息
     */
    @OnClick(R.id.title_message)
    void message() {
        if (isLogin) {
            startActivity(new Intent(context, MessageActivity.class));
        } else {
            Intent in = new Intent(getActivity(), LoginActivity.class);
            in.putExtra("isBack", true);
            startActivity(in);
        }
    }

    /**
     * 选择城市
     */
    @OnClick(R.id.title_city)
    void checkCity() {
        isShowMessage = true;
        CityPicker cp = new CityPicker.Builder(context)
                .city(city_sheng)
                .province(city_shi)
                .provinceCyclic(false)
                .textColor(Color.parseColor("#696969"))
                .textSize(15)
                .cityCyclic(false)
                .districtCyclic(false)
                .visibleItemsCount(7)
                .onlyShowProvinceAndCity(true)
                .itemPadding(15)
                .build();
        cp.show();

        cp.setOnCityItemClickListener(new CityPicker.OnCityItemClickListener() {
            @Override
            public void onSelected(String... citySelected) {
                isReflush = true;
                //顺序 省市""
                String data = String.format("%s-%s", citySelected[0], citySelected[1]);
                city_sheng = citySelected[0]; //省 name
                city_shi = citySelected[1]; //市 name
                city_code = citySelected[2];//市  编码
                city.setText(citySelected[1]);

                pullNum = 1;
                if (dataList != null) {
                    dataList.clear();
                    adapter.notifyDataSetChanged();
                }
                if (citySelected[0].contains("全部")) {
                    city_code = "";
                    initData(city_code, type, pullNum, page_size, UserType, YongTu, EDu, QiXian, SheBao, GongJiJin, LeiXing, ZhiZhao, DuiGong, DuiSi);   //post 列表数据
                } else {
                    initData(city_code, type, pullNum, page_size, UserType, YongTu, EDu, QiXian, SheBao, GongJiJin, LeiXing, ZhiZhao, DuiGong, DuiSi);  //post 列表数据
                }

            }

            @Override
            public void onCancel() {

            }
        });
    }

    /**
     * 初始化定位
     *
     * @author hongming.wang
     * @since 2.8.0
     */
    private void initLocation() {
        mlocationClient = new AMapLocationClient(context);
        //初始化定位参数
        mLocationOption = new AMapLocationClientOption();
        //设置返回地址信息，默认为true
        mLocationOption.setNeedAddress(true);
        //设置定位监听
        mlocationClient.setLocationListener(this);
        //设置定位模式为高精度模式，Battery_Saving为低功耗模式，Device_Sensors是仅设备模式
        mLocationOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Battery_Saving);
        //设置定位间隔,单位毫秒,360000
        mLocationOption.setInterval(2000);
        //设置定位参数
        mlocationClient.setLocationOption(mLocationOption);
        //启动定位
        mlocationClient.startLocation();
    }


    public void initView() {
        appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
            @Override
            public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
                if (verticalOffset >= 0) {
                    mRefreshLayout.setEnabled(true);
                } else {
                    mRefreshLayout.setEnabled(false);
                }
            }
        });
        final LinearLayoutManager mLayoutManager = new LinearLayoutManager(context);
        recyclerView.setLayoutManager(mLayoutManager);
        adapter = new HomeAdapter(context, dataList, idList);
        recyclerView.setAdapter(adapter);

        adapter.setOnItemClickListener(onItemClckListener);

        mRefreshLayout.setProgressBackgroundColorSchemeResource(android.R.color.white);
        mRefreshLayout.setProgressViewOffset(true, -20, 100);
        // 设置下拉进度的主题颜色
        mRefreshLayout.setColorSchemeResources(R.color.colorAccent, R.color.borrowHelp_background, R.color.lvse);
        mRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                pullNum = 1;
                isReflush = true;
                initData(city_code, type, pullNum, page_size, UserType, YongTu, EDu, QiXian, SheBao, GongJiJin, LeiXing, ZhiZhao, DuiGong, DuiSi);
            }
        });
        recyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
                super.onScrollStateChanged(recyclerView, newState);
                int lastVisibleItemPosition = mLayoutManager.findLastVisibleItemPosition();
                if (lastVisibleItemPosition + 1 == adapter.getItemCount()) {
                    boolean isRefreshing = mRefreshLayout.isRefreshing();
                    if (isRefreshing) {
                        adapter.notifyItemRemoved(adapter.getItemCount());
                        return;
                    }
                    if (!isLoading) {
                        isLoading = true;
                        isShowMessage = false;
                        pullNum++;
                        initData(city_code, type, pullNum, page_size, UserType, YongTu, EDu, QiXian, SheBao, GongJiJin, LeiXing, ZhiZhao, DuiGong, DuiSi);
                    } else {

                    }
                }
            }

            @Override
            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                super.onScrolled(recyclerView, dx, dy);
                int lastVisibleItemPosition = mLayoutManager.findLastVisibleItemPosition();
            }
        });


        progressDialog = new ProgressDialog(getActivity());
        progressDialog.setCancelable(false);


        getPoPu();


    }


    /**
     * 列表点击事件
     */
    HomeAdapter.OnRecyclerViewItemClickListener onItemClckListener = new HomeAdapter.OnRecyclerViewItemClickListener() {
        @Override
        public void onItemClick(int position) {
            if (!isLogin) {
                Intent in = new Intent(getActivity(), LoginActivity.class);
                in.putExtra("isBack", true);
                startActivity(in);
            } else {
                dataList.get(position).setRead(true);
                adapter.notifyDataSetChanged();
                addListData(dataList.get(position).getId());
                Bundle bundle = new Bundle();
                bundle.putString("url", Api.HOST + "/jqb_qdb/Grab_single.html" +
                        "?app_key=ZQXQ-HYQDB" + "&source=1" +
                        "&client_id=" + BorrowHelpApp.get().getPhoneIMEI() +
                        "&channel=1" +
                        "&app_version=" + BorrowHelpApp.get().getVersion() +
                        "&order_id=" + dataList.get(position).getId());
                bundle.putInt("mm", 1);
                bundle.putInt("status", dataList.get(position).getLoan_status());

                SharedHelper.put(getActivity(), "mm", 1);
                SharedHelper.put(getActivity(), "status", dataList.get(position).getLoan_status());

                SharedHelper.put(getActivity(), "uuser_id", dataList.get(position).getUser_id());
                SharedHelper.put(getActivity(), "id", dataList.get(position).getId());

                Intent intent = new Intent(getActivity(), WebViewActivity.class);
                intent.putExtras(bundle);
                startActivityForResult(intent, RQ_WEBVIEW);


            }
        }
    };

    private void addListData(String ids) {
        idList.add(ids);
        Log.v("TAG","____(:"+idList);
    }


    /**
     * 设置banner
     *
     * @param list
     */
    private void loadBanner(final List<BannerBean.bannerList> list) {
        HolderAttr.builder()
                .setBanners(list)//加载资源集合
                .setAutoLooper(true)//是否自动轮播
                .setLooperTime(3000)//设置轮播时间（单位：毫秒）
                .setSwitchDuration(800)//设置切换
                //设置Banner点击事件
                .setBannerClickListener(new BannerClickListener() {
                    @Override
                    public void onBannerClick(int p) {
                        //点击位置索引 0~
                        //判断URL是否为空， 为空不能跳转至H5
                        if(isLogin) {
                            if (!TextUtils.isEmpty(list.get(p).getBanner_link())) {
                                Bundle bundle = new Bundle();
                                bundle.putString("url", list.get(p).getBanner_link());
                                bundle.putInt("mm", 7);
                                Intent intent2 = new Intent(getActivity(), WebViewActivity.class);
                                intent2.putExtras(bundle);
                                startActivityForResult(intent2, GOTOBANNER);
                            }
                        }else {
                            startActivity(new Intent(getActivity(),LoginActivity.class));
                        }
                    }
                })
                //设置Banner图片加载器可以使用图片加载框架
                .setBannerLoader(new ImageViewBannerLoader() {
                    @Override
                    public void loadImage(Context context, Object path, ImageView view) {
                        /* 提供参数与控件，自定加载图片的实现方式
                         * -选择使用默认提供的ImageLoader加载图片
                         */
                        BannerBean.bannerList br = (BannerBean.bannerList) path;
                        SimpleImageLoader.getInstence().loadImage(br.getBanner_url(), view);
                    }

                    /**
                     * 设置 默认加载图片
                     * @param context
                     * @return
                     */
                    @Override
                    public ImageView createView(Context context) {
                        ImageView imageView = new ImageView(context);
                        imageView.setBackgroundResource(R.drawable.img_home_banner2);
                        return imageView;
                    }
                }).builder(banner_holder).start();
    }


    /**
     * 借款类型
     */
    private void getPoPu() {
        View wh = LayoutInflater.from(context).inflate(R.layout.wheel_view, null);
        final WheelView picker = (WheelView) wh.findViewById(R.id.type_wheel);
        popupWindow = new WPopupWindow(wh);
        picker.addData("全部");
        picker.addData("可抢订单");
        picker.addData("优质订单");
        picker.addData("免费订单");

        picker.setCenterItem("");
        picker.setCenterItem("4");
        picker.setCenterItem("3");
        picker.setCenterItem("5");

        picker.setCenterItem(0);

        wh.findViewById(R.id.type_ok).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                money_type.setText(picker.getCenterItem().toString());
                if (picker.getCenterItem().toString().equals("全部")) {
                    type = "";
                } else if (picker.getCenterItem().toString().equals("可抢订单")) {
                    type = "4";
                } else if (picker.getCenterItem().toString().equals("优质订单")) {
                    type = "3";
                } else if (picker.getCenterItem().toString().equals("免费订单")) {
                    type = "5";
                }
                if (dataList != null) {
                    dataList.clear();
                    adapter.notifyDataSetChanged();
                }

                isReflush = true;
                isShowMessage = true;
                pullNum = 1;
                initData(city_code, type, pullNum, page_size, UserType, YongTu, EDu, QiXian, SheBao, GongJiJin, LeiXing, ZhiZhao, DuiGong, DuiSi);   //post 列表数据
                popupWindow.dismiss();
            }
        });

        wh.findViewById(R.id.type_no).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                popupWindow.dismiss();
            }
        });
    }


    /**
     * 借款类型
     */
    @OnClick(R.id.gd_type)
    void inCheckType() {
        popupWindow.showAtLocation(gd_type, Gravity.BOTTOM, 0, 0);
    }

    /**
     * 筛选
     */
    @OnClick(R.id.home_screening)
    void screening() {
        startActivityForResult(new Intent(getActivity(), HomeScreeningActivity.class), 0x11);
    }


    @Override
    public void showToast(String str) {
        if (t == null) {
            t = Toast.makeText(context, str, Toast.LENGTH_SHORT);
        } else {
            t.setText(str);
            t.setDuration(Toast.LENGTH_SHORT);
        }
        t.show();
    }

    @Override
    public void setViewDta(FragmentGrabSingleBean bean) {
        mRefreshLayout.setRefreshing(false);
        bea = bean;
        if (isReflush) {
            isReflush = false;
            dataList.clear();
        }
        if (isLoading) {
            if (bean.getList().size() == 0) {
                showToast("别扯了~ 我是有底线的！");
            }
            isLoading = false;
        }
        if (bean.getList().size() > 0) {

            for (int i = 0; i <bean.getList().size() ; i++) {
                String id=bean.getList().get(i).getId();
                for (int j = 0; j <idList.size(); j++) {
                    if (id.contains(idList.get(j))){
                        bean.getList().get(i).setRead(true);
                        break;
                    }else {
                        bean.getList().get(i).setRead(false);
                    }
                }
            }
            dataList.addAll(bean.getList());
            adapter.notifyDataSetChanged();
            tvMessage.setVisibility(View.GONE);
        } else {
            if (isShowMessage) {
                isShowMessage = true;
                tvMessage.setVisibility(View.VISIBLE);
            }
        }
    }


    @Override
    public void setBannerHolder(BannerBean bean) {
        loadBanner(bean.getList());
    }

    /**
     * 垂直跑马灯
     *
     * @param grabsBean
     */
    @Override
    public void findRealTimeGrab(GrabsBean grabsBean) {
        List<String> info = new ArrayList<>();
        if (grabsBean.getGrabs() != null) {
//            setAnimation1();
            info.addAll(grabsBean.getGrabs());
            marqueeView.startWithList(info);
        }
    }

    @Override
    public void noData() {
        isLoading = false;
        mRefreshLayout.setRefreshing(false);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        presenter.end();
    }

    @Override
    public void disPlay() {
        progressDialog.setMessage("正在加载，请等待");
        progressDialog.show();
    }

    @Override
    public void disMiss() {
        progressDialog.dismiss();
    }


    @Override
    public void onLocationChanged(AMapLocation amapLocation) {
        if (amapLocation != null) {
            if (amapLocation.getErrorCode() == 0) {
                //定位成功回调信息，设置相关消息
                amapLocation.getLocationType();//获取当前定位结果来源，如网络定位结果，详见定位类型表
                amapLocation.getProvince();//省信息
                amapLocation.getCity();//城市信息
                amapLocation.getCityCode();//城市编码
                amapLocation.getAdCode();//地区编码
                city_sheng = amapLocation.getProvince();//省信息
                city_shi = amapLocation.getCity();//城市信息
                SharedHelper.get(getActivity(), "shi", amapLocation.getProvince());
                SharedHelper.get(getActivity(), "city", amapLocation.getCity());

                SharedHelper.put(getActivity(), "citys", city_sheng + "-" + city_shi);
                SharedHelper.put(getActivity(), "city_code", amapLocation.getAdCode());
            } else {

            }
        }
    }


    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        switch (resultCode) {
            case Activity.RESULT_OK:
                if (requestCode == 0x11) {
                    Bundle bundle = data.getExtras();
                    YongTu = bundle.getString("YongTu");
                    ChengShi = bundle.getString("ChengShi");
                    EDu = bundle.getString("EDu");
                    QiXian = bundle.getString("QiXian");
                    UserType = String.valueOf(bundle.getInt("user_type"));

                    SheBao = bundle.getString("SheBao") == null ? "" : bundle.getString("SheBao");
                    GongJiJin = bundle.getString("GongJiJin") == null ? "" : bundle.getString("GongJiJin");

                    LeiXing = bundle.getString("LeiXing") == null ? "" : bundle.getString("LeiXing");
                    ZhiZhao = bundle.getString("ZhiZhao") == null ? "" : bundle.getString("ZhiZhao");
                    DuiGong = bundle.getString("DuiGong") == null ? "" : bundle.getString("DuiGong");
                    DuiSi = bundle.getString("DuiSi") == null ? "" : bundle.getString("DuiSi");

                    Log.e("tag", "_type" + type + "_usertype" + UserType + "_YongTu:" + YongTu + "_ChengShi:" + ChengShi + "_EDu:" + EDu + "_QiXian:" + QiXian + "_SheBao:" + SheBao + "_GongJiJin:" + GongJiJin + "_LeiXing:" + LeiXing + "_ZhiZhao:" + ZhiZhao + "_DuiGong:" + DuiGong + "_DuiSi:" + DuiSi);

                    city_code = ChengShi;

                    isReflush = true;
                    isShowMessage = true;
                    pullNum = 1;
                    initData(city_code, type, pullNum, page_size, UserType, YongTu, EDu, QiXian, SheBao, GongJiJin, LeiXing, ZhiZhao, DuiGong, DuiSi);   //post 列表数据
                }else if(requestCode==GOTOBANNER){
                    isReflush = true;
                    isShowMessage = true;
                    pullNum = 1;
                    money_type.setText("免费订单");
                    type="5";
                    initData(city_code, type, pullNum, page_size, UserType, YongTu, EDu, QiXian, SheBao, GongJiJin, LeiXing, ZhiZhao, DuiGong, DuiSi);   //post 列表数据
                }
                break;
        }
    }
}
